package cn.com.dcsgo.service.impl;

import cn.com.dcsgo.mapper.ScheduleMapper;
import cn.com.dcsgo.pojo.Schedule;
import cn.com.dcsgo.service.ScheduleService;
import cn.com.dcsgo.utils.PageResult;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

/**
 * ScheduleService
 *
 * @author Dcsgo
 * @since 2025/3/8 16:24
 */
@Service
public class ScheduleServiceImpl implements ScheduleService {
    private final ScheduleMapper scheduleMapper;

    public ScheduleServiceImpl(ScheduleMapper scheduleMapper) {
        this.scheduleMapper = scheduleMapper;
    }

    @Override
    public PageResult<Schedule> findAllByPage(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        PageInfo<Schedule> pageInfo = new PageInfo<>(scheduleMapper.queryAll());
        return PageResult.of(pageInfo);
    }

    @Override
    public int deleteById(Integer id) {
        return scheduleMapper.deleteById(id);
    }

    @Override
    public int addOne(Schedule schedule) {
        return scheduleMapper.insertOne(schedule);
    }

    @Override
    public int updateById(Schedule schedule) {
        return scheduleMapper.updateById(schedule);
    }


}
